package com.cby.android.olive.encrypt

/**
 * Description:Base64Utils-- Base64的加解密
 *
 * @author 陈宝阳
 * @create 2020/8/3 16: 53
 */
object Base64Utils {

    @JvmStatic
    fun decode(data: String?): String? {
        return if (null == data) {
            null
        } else String(
            Base64.decode(
                data.toByteArray(),
                Base64.NO_WRAP
            )
        )
    }

    @JvmStatic
    fun decodeToByte(data: String?): ByteArray? {
        return if (null == data) {
            null
        } else Base64.decode(
            data.toByteArray(),
            Base64.NO_WRAP
        )
    }

    @JvmStatic
    fun encode(data: String?): String? {
        return if (null == data) {
            null
        } else Base64.encodeToString(
            data.toByteArray(),
            Base64.NO_WRAP
        )
    }

    @JvmStatic
    fun encode(data: ByteArray?): String? {
        return if (null == data) {
            null
        } else Base64.encodeToString(
            data,
            Base64.NO_WRAP
        )
    }
}